package com.example.xinhuaxin.dao;


import com.example.xinhuaxin.entity.Card;
import com.example.xinhuaxin.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserDao {
//    确认用户是否已经注册
    @Select("select * from USER_INFO where USER_ACCOUNT = #{USER_ACCOUNT}")
    public User userCheck(@Param("USER_ACCOUNT")String account);
//    用户登录
    @Select("select * from USER_INFO where USER_ACCOUNT = #{USER_ACCOUNT} and USER_PASSWORD = #{USER_PASSWORD}")
    public User userLogin(@Param("USER_ACCOUNT")String account, @Param("USER_PASSWORD")String pwd);
//  用户注册
    @Insert("insert into USER_INFO (USER_ID, USER_NAME, USER_ADDRESS, USER_TEL, USER_ACCOUNT, USER_PASSWORD, USER_AGE) values (#{user_id}, #{user_name}, #{user_address}, #{user_tel}, #{user_account}, #{user_password}, #{user_age})")
    public void register(User user);
//    用户信息查找
    @Select("select * from USER_INFO where USER_ID = #{user_id}")
    public User getUserInfo(String user_id);
//    查询用户绑定的银行卡列表
    @Select("select CARD_ID from USER_CARD where USER_ID = #{user_id} and state = 1")
    public List<Integer> getUserCardList(String user_id);
}

